package com.zzjx.demo.service.impl;

import com.zzjx.demo.event.UserInfoEvent;
import com.zzjx.demo.listener.UserInfoEventBusListener;
import com.zzjx.demo.publishEnum.EventBusEnum;
import com.zzjx.demo.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

/**
 * @author zhaojiaxu
 * @date 2022/02/20 15:35
 **/
@Service
@Slf4j
public class UserInfoServiceImpl implements UserInfoService, InitializingBean {
    @Override
    public String publishUserEvent(UserInfoEvent userInfoEvent) {
        return null;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        //订阅修改用户信息事件
        EventBusEnum.MODIFY_INFO_EVENT.registerEvent((UserInfoEventBusListener<UserInfoEvent>) event -> {
            log.info("触发修改用户信息基本事件 event:{}", event.toString());
            if (event != null && event.isSuccess()) {
                //
                //修改缓存
                System.out.println("ok");
                log.info("开始修改缓存");
            }
        });
        //订阅修改公司修改事件等等
    }
}

